﻿using System.Collections;
using System.Collections.Generic;
using System.Threading;
using UnityEngine;
using UnityEngine.UI;

public class CardDisplay : MonoBehaviour
{
    public Text nameText;
    public Text attackText;
    public Text healthText;
    public Text effectText;
    public Text shieldText;

    public Image backgroundImage;

    public Card card;
    // Start is called before the first frame update
    void Start()
    {
        ShowCard();
    }

    // Update is called once per frame
    void Update()
    {

    }
    public void ShowCard()
    {
        if (card is AttackCard)
        {
            var attackcard = card as AttackCard;
            nameText.text = card.cardName;
            attackText.text = attackcard.attack.ToString();
            //隐藏文字描述
            healthText.text = attackcard.mana.ToString();
            effectText.gameObject.SetActive(false);
            shieldText.gameObject.SetActive(false);
        }
        else if (card is SpellCard)
        {
            var spell = card as SpellCard;
            effectText.text = spell.effect;
            nameText.text = card.cardName;
            attackText.text = spell.effectvalue.ToString();
            healthText.text = spell.mana.ToString();
            shieldText.gameObject.SetActive(false);
        }
        else if (card is CharacterCard)
        {
            var character = card as CharacterCard;
            nameText.text = card.cardName;
            effectText.text = character.skill;
            attackText.text = character.mana.ToString();
            healthText.text = character.healthPoint.ToString();
            shieldText.text = character.shield.ToString();
        }
        else if (card is ShieldCard)
        {
            var shieldCard = card as ShieldCard;
            nameText.text = card.cardName;
            effectText.gameObject.SetActive(false);
            attackText.gameObject.SetActive(false);
            healthText.text = shieldCard.mana.ToString();
            shieldText.text = shieldCard.Shield.ToString();
        }
    }
}
